import { Component } from '@angular/core';
import {App, IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {StorageProvider} from "@providers/storage";
import {DialogProvider} from "@providers/dialog";

/**
 * Generated class for the CustomerMyPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-customer-my',
  templateUrl: 'customer-my.html',
})
export class CustomerMyPage {

  userInfo: any = this.storageProvider.read("userInfo");
  theadd: any[] = [];//默认地址

  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              private storageProvider:StorageProvider,
              private modalCtrl:ModalController,
              private dialogProvider:DialogProvider,
              private app:App,) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad CustomerMyPage');
    console.info(this.userInfo)
  }

  push(page: string) {
    this.navCtrl.push(page);
  }

  addressManagement(page: string) {
    let modal = this.modalCtrl.create(page);
    modal.onDidDismiss((da) => {
      if (da) {
        let a: any[] = [];
        a.push(da);
        this.theadd = a;
      }
    });
    modal.present();
  }

  logout(page: string) {
    this.dialogProvider.showConfirm(() => {
      this.app.getRootNav().setRoot(page);
    }, "是否退出登录？")
  }

}
